using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace TelephoneDirectory
{
    class MdiMenu
    {
        static void Menu()
        {
            Console.WriteLine("1. Them moi thue bao...");
            Console.WriteLine("2. Sua thong tin thue bao...");
            Console.WriteLine("3. Xoa theu bao...");
            Console.WriteLine("4. Tim kiem theo ten...");
            Console.WriteLine("5. Tim kiem theo so dien thoai...");
            Console.WriteLine("6. Xem danh sach thue bao...");
            Console.WriteLine("7. Thoat...");
            Console.Write("Chon chuc nang:");
        }
        static void AddNewSubscibers()
        { 
        
        }
        static void CreateFile()
        {
            XmlTextWriter write = new XmlTextWriter("telephone.xml", Encoding.UTF8);
            write.WriteStartDocument(true);
            write.Formatting = Formatting.Indented;
            write.Indentation = 5;
            write.WriteStartElement("Contacts");
            CreateNode("thai 1", "1", "1", "11", write);
            CreateNode("thai 2", "2", "2", "22", write);
            CreateNode("thai 3", "3", "3", "33", write);
            write.WriteEndElement();
            write.WriteEndDocument();
            write.Close();
        }
        static void CreateNode(string _Name, string _Code, string _Address, string _PhoneNumber, XmlTextWriter write)
        {
            //XmlAttribute attribute=new 
            write.WriteStartElement("Phone");
            write.WriteStartElement("Name");
            write.WriteString(_Name);
            write.WriteEndElement();
            write.WriteStartElement("Code");
            write.WriteString(_Code);
            write.WriteEndElement();
            write.WriteStartElement("Address");
            write.WriteString(_Address);
            write.WriteEndElement();
            write.WriteStartElement("PhoneNumber");
            write.WriteString(_PhoneNumber);
            write.WriteEndElement();
            write.WriteEndElement();
        }
        static void AddNode()
        {
            Add objAdd = new Add();
            objAdd.add(objAdd._Name, objAdd._Code, objAdd._Address, objAdd._PhoneNumber);
        }

        static void SearchByName()
        {
            Sreach objSearch = new Sreach();
            Console.WriteLine("\nNhap ten thue bao can tim : ");
            string Name = Console.ReadLine();
            objSearch.SearchByName(Name);
        }

        static void SearchByNumber()
        {
            Sreach objSearch = new Sreach();
            Console.WriteLine("\nNhap so thue bao can tim : ");
            string Number = Console.ReadLine();
            objSearch.SearchByNumer(Number);
        }

        static void Main(string[] args)
        {           
        lap:
            Menu();
            string ch;
            ch = Console.ReadLine().ToString();
            switch (ch)
            {
                case "1":
                    {
                        AddNode();
                        goto lap;
                    }
                case "2":
                    {
                        Console.WriteLine(ch); Console.ReadKey(); Console.Clear(); goto lap;
                    }
                case "3":
                    {
                        Console.WriteLine(ch); Console.ReadKey(); Console.Clear(); goto lap;
                    }
                case "4":
                    {
                        SearchByName();
                        goto lap;
                    }
                case "5":
                    {
                        SearchByNumber();
                        goto lap;
                    }
                case "6":
                    {
                        Console.WriteLine(ch); Console.ReadKey(); Console.Clear(); goto lap;
                    }
                case "7": break;
                default:
                    {
                        Console.Write("Chuc nang khong dung!"); Console.ReadKey(); Console.Clear(); goto lap; 
                    }
            }
        }
    }
}
